﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Collections.Generic;
using System.Threading;
using System.Diagnostics;
namespace WPFExcelReport
{
    public partial class SXNVA06 : DocumentBase
    {
        #region ==IsVA02===========
        public static readonly DependencyProperty IsVA02Property = DependencyProperty.Register("IsVA02",
            typeof(bool), typeof(SXNVA06),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVA02Changed));
        public bool IsVA02
        {
            get
            {
                return (bool)GetValue(IsVA02Property);
            }
            set
            {
                SetValue(IsVA02Property, value);
            }
        }
        private static void OnIsVA02Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as SXNVA06;
            if (src != null)
            {
                src.IsVA02 = (bool)e.NewValue;
            }
        }

        #endregion

        #region ==IsVA06===========
        public static readonly DependencyProperty IsVA06Property = DependencyProperty.Register("IsVA06",
            typeof(bool), typeof(SXNVA06),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVA06Changed));
        public bool IsVA06
        {
            get
            {
                return (bool)GetValue(IsVA06Property);
            }
            set
            {
                SetValue(IsVA06Property, value);
            }
        }
        private static void OnIsVA06Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as SXNVA06;
            if (src != null)
            {
                src.IsVA06 = (bool)e.NewValue;
            }
        }

        #endregion

        #region ==IsVA09===========
        public static readonly DependencyProperty IsVA09Property = DependencyProperty.Register("IsVA09",
            typeof(bool), typeof(SXNVA06),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVA09Changed));
        public bool IsVA09
        {
            get
            {
                return (bool)GetValue(IsVA09Property);
            }
            set
            {
                SetValue(IsVA09Property, value);
            }
        }
        private static void OnIsVA09Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as SXNVA06;
            if (src != null)
            {
                src.IsVA09 = (bool)e.NewValue;
            }
        }

        #endregion

        VSXNVA06 vm;
        public SXNVA06()
        {
            vm = new VSXNVA06();
            DataContext = vm;
            InitializeComponent();
            this.Name = "工艺管理";
            ReSetTab();
            IsVA06 = true;
            SetUp();
        }

        private void SetUp()
        {
            //默认注释随客户不同而不同，所以放在这里
            //根据01-，02-，03-等等对备注类型进行分类。分类方法可以依据客户不同自己定义，主要用于报表和显示。例如01如果代表成份，则可以在打印时处理。保存在TXTKON表的某个自duang
            List<string> deftxt = new List<string>();
            deftxt.Add("01-备注:");
            cMaster.DEFWSTXT = deftxt;
            deftxt = new List<string>();
            deftxt.Add("00-please type your remark after remove this:");
            cMaster.DEFTXT = deftxt;
            cMaster.VALBTYP = "SXNVALB";
            cMaster.IsExtProd = true;
           
            if (!System.IO.Directory.Exists("T:"))
            {
                
                MessageBox.Show("请先建立T盘映射，就看到图片！");
            }
            cMaster.IMAGEPATH = "T:\\Images";
            /*if (cMaster.MV.IsITX)
            {
                cMaster.IMAGEPATH = "d:\\Images";
            }*/
        }
     
        private void ReSetTab()
        {
            IsVA02 = false;
            IsVA06 = false;
            IsVA09 = false;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return;
                if (IsLoaded)
                    return;
                IsLoaded = true;

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return;

        }

        private void ShowVA02Command(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            IsVA02 = true;
        }

        private void ShowVA06Command(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            IsVA06 = true;
        }

        private void ShowVA09Command(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            IsVA09 = true;
        }
    }
}
